import {searchJson} from '@/api/index.js';

// 材料：
let state = {
    searchList: {},
    total: 0
};

// 加工：
let getters = {
    goodsList(state) {
        return state.searchList.goodsList;
    },
    trademarkList(state) {
        return state.searchList.trademarkList;
    },
    attrsList(state) {
        return state.searchList.attrsList;
    }
};

// 厨师：
let mutations = {
    SEARCHLIST(state, value) {
        state.searchList = value;
    },
    TOTAL(state, value) {
        state.total = value;
    }
};

// 迎宾：
let actions = {
    async getSearchList({state, dispatch, commit}, searchParams) {
        console.log('请求参数', searchParams);
        let result = await searchJson(searchParams);
        console.log('响应数据', result.data);
        if (result.code === 200) {
            commit('SEARCHLIST', result.data);
            commit('TOTAL', result.data.total);
        }
    }
};

// 向外共享数据
export default {
    state,
    getters,
    mutations,
    actions
};



